package demo01;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-04
 * Time: 19:34
 */
//匿名内部类实现多线程
public class Test04 {
    public static void main(String[] args) {
        Thread t =new Thread() {
            @Override
            public void run() {
               while(true) {
                    System.out.println("多线程");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    } finally {
                    }
               }
            }
        };
        t.start();
        while(true) {
            System.out.println("主线程");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
            }
        }
    }
}
